//
//  LGInspectHeadView.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/6/30.
//

#import "LGInspectHeadView.h"

#define baseWidth     (Screen_W-viewPix(56))
#define dateWidth     (88/343.0)*baseWidth
#define itemWidth     (95/343.0)*baseWidth

@interface LGInspectHeadView()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIView *lineView1;
/**   */
@property (nonatomic , strong)UIView *lineView2;
/**   */
@property (nonatomic , strong)UIView *lineView3;
/**   */
@property (nonatomic , strong)UILabel *dateLabel;
/**   */
@property (nonatomic , strong)UILabel *resultLabel;
/**   */
@property (nonatomic , strong)UILabel *unitLabel;
/**   */
@property (nonatomic , strong)UILabel *rangeLabel;

@end

@implementation LGInspectHeadView

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.clipsToBounds = YES;
    self.backgroundColor = [UIColor colorWithString:@"#F9F9F9"];
    [self addSubview:self.baseView];
    [self.baseView addSubview:self.dateLabel];
    [self.baseView addSubview:self.resultLabel];
    [self.baseView addSubview:self.unitLabel];
    [self.baseView addSubview:self.rangeLabel];
    [self.baseView addSubview:self.lineView1];
    [self.baseView addSubview:self.lineView2];
    [self.baseView addSubview:self.lineView3];
 
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).offset(viewPix(5));
        make.left.equalTo(self).offset(viewPix(16));
        make.right.equalTo(self).offset(-viewPix(16));
        make.bottom.equalTo(self).offset(viewPix(10));
    }];
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(self.baseView);
        make.width.equalTo(@(dateWidth));
        make.height.equalTo(@(viewPix(36)));
    }];
    [self.resultLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.height.equalTo(self.dateLabel);
        make.left.equalTo(self.dateLabel.mas_right);
        make.width.equalTo(@(itemWidth));
    }];
    [self.unitLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.height.equalTo(self.dateLabel);
        make.left.equalTo(self.resultLabel.mas_right);
        make.width.equalTo(@(itemWidth));
    }];
    [self.rangeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.height.equalTo(self.dateLabel);
        make.left.equalTo(self.unitLabel.mas_right);
        make.right.equalTo(self.baseView);
    }];
    [self.lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.baseView);
        make.left.equalTo(self.dateLabel.mas_right);
        make.width.equalTo(@(0.5));
    }];
    [self.lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.baseView);
        make.left.equalTo(self.resultLabel.mas_right);
        make.width.equalTo(@(0.5));
    }];
    [self.lineView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.baseView);
        make.left.equalTo(self.unitLabel.mas_right);
        make.width.equalTo(@(0.5));
    }];
}

-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B2BDC7" offset:CGSizeMake(0, 2) opacity:0.15 radius:10];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UIView *)lineView1{
    if(!_lineView1){
        _lineView1 = [[UIView alloc] init];
        _lineView1.backgroundColor = [UIColor colorWithString:@"#F2F2F2"];
    }
    return _lineView1;
}


-(UIView *)lineView2{
    if(!_lineView2){
        _lineView2 = [[UIView alloc] init];
        _lineView2.backgroundColor = [UIColor colorWithString:@"#F2F2F2"];
    }
    return _lineView2;
}

-(UIView *)lineView3{
    if(!_lineView3){
        _lineView3 = [[UIView alloc] init];
        _lineView3.backgroundColor = [UIColor colorWithString:@"#F2F2F2"];
    }
    return _lineView3;
}

-(UILabel *)dateLabel{
    if(!_dateLabel){
        _dateLabel = [UILabel lableWithText:@"日期" colorString:@"#666666" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _dateLabel;
}

-(UILabel *)resultLabel{
    if(!_resultLabel){
        _resultLabel = [UILabel lableWithText:@"结果" colorString:@"#666666" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _resultLabel;
}

-(UILabel *)unitLabel{
    if(!_unitLabel){
        _unitLabel = [UILabel lableWithText:@"单位" colorString:@"#666666" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _unitLabel;
}


-(UILabel *)rangeLabel{
    if(!_rangeLabel){
        _rangeLabel = [UILabel lableWithText:@"参考值" colorString:@"#666666" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _rangeLabel;
}



@end
